package demo1;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNextInt()) {
			int m = scanner.nextInt();
			int n = scanner.nextInt();
			boolean[][] st = new boolean[m][n];
			String[] map = new String[m];
			int x = 0, y = 0;
			for(int i = 0; i<m; i++) {
				map[i] = scanner.next(); 
				for(int j = 0; j<n; j++) {
					if(map[i].charAt(j)== '@' ) {
						x = i;
						y = j;
					}
				}
			}
			int[] xx = {1,-1,0,0};
			int[] yy = {0,0,1,-1};
			int count = 0;
			Queue<int[]> queue = new LinkedList<>();
			queue.add(new int[] {x,y});
			st[x][y]= true; 
			while (!queue.isEmpty()) {
				int[] t = queue.poll();
				int dx = t[0];
				int dy = t[1];
				count++;
				for(int i = 0; i<4; i++) {
					int a = dx + xx[i];
					int b = dy + yy[i];
					if(a>=0 && a<m && b>=0 && b<n && map[a].charAt(b)== '.' && !st[a][b]) {
						queue.add(new int[] {a,b});
						st[a][b]= true; 
					}
				}
			}
			System.out.println(count);
		}
		
	}
}